

$(function(){
	var audioElement2 = document.createElement('audio');
	audioElement2.setAttribute('src', URL + '/media/friendrequest.mp3' );

	audioElement2.addEventListener("load", function() {

	}, true);


	var pusher = new Pusher(PUSHER_APP_KEY);
	var channel = pusher.subscribe('my-channel');

	channel.bind('accepted-group-request', function(data) {
		
		if(data.receiver_id == SS_USER_ID)
		{
			audioElement2.play();
			var counter = parseInt($('#counterNotif').text());
			counter++;
			$('#counterNotif').text(counter).show();

		}
	});

	channel.bind('accepted-request', function(data) {

		if(data.user_id == SS_USER_ID)
		{
			audioElement2.play();
			var counter = parseInt($('#counterNotif').text());
			counter++;
			$('#counterNotif').text(counter).show();

		}
	});

	channel.bind('comment-added', function(data) {
		console.log(data);
		if(data.receiver_id == SS_USER_ID && data.user_id != SS_USER_ID)
		{
			audioElement2.play();
			var counter = parseInt($('#counterNotif').text());
			counter++;
			$('#counterNotif').text(counter).show();		
		}
	});

	channel.bind('status-update', function(data) {
		//console.log(data);
		if(data.user_id == SS_USER_ID && data.sender_id != SS_USER_ID)
		{
			audioElement2.play();
			var counter = parseInt($('#counterNotif').text());
			counter++;
			$('#counterNotif').text(counter).show();

		}
	});
});	






